package com.jerry.chat.dao;

import com.jerry.chat.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("SELECT * FROM user WHERE id=#{id} AND password=#{password}")
    User getForLogin(@Param("id") String id, @Param("password") String password);

    @Select("SELECT * FROM user WHERE id=#{id}")
    User getById(String id);

    @Insert("INSERT INTO user(id, name, password) values(#{id}, #{name}, #{password})")
    void Insert(User user);

    @Update("Update user SET cid = (#{cid}) WHERE id = #{id}")
    void updateCid(@Param("id") String id, @Param("cid") String cid);

    @Select("Select * from user WHERE id in (SELECT id2 FROM friend_relation_ship WHERE friend_relation_ship.id1 = #{id})")
    List<User> getFriendList(String id);

    @Update("UPDATE user SET facepath = #{facepath} WHERE id = #{id}")
    void updateFacepath(User user);
}
